#include"comm.hpp"
#include<unistd.h>

int main()
{
    //获取共享内存
    key_t shmid=GetShm();

    //关联
    char* addr=(char*)shmat(shmid,nullptr,0);

    int m=mkfifo(FIFOFILE,MODE);
    int fd=open(FIFOFILE,O_WRONLY);
    //通信
    while(true){
        char c;
        write(fd,&c,1);

        cout<<"Please input: ";
        fgets(addr,4096,stdin);
        sleep(1);
    }

    //去关联
    int n=shmdt(addr);
    if(n==-1){
        perror("shmdt error\n");
        exit(-1);
    }
    return 0;
}